<template>
  <div v-if="visible" class="input-dialog">
    <input v-model="inputValue" placeholder="请输入信息" />
    <button @click="confirm">确认</button>
    <button @click="cancel">取消</button>
  </div>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      inputValue: '',
    };
  },
  methods: {
    confirm() {
      this.$emit('confirm', this.inputValue); // 触发确认事件并传递输入值
      this.inputValue = ''; // 清空输入框
    },
    cancel() {
      this.$emit('cancel'); // 触发取消事件
      this.inputValue = ''; // 清空输入框
    },
  },
};
</script>

<style scoped>
.input-dialog {
  background-color: #fff;
  padding: 20px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
</style>
